package com.dyh.quickdemozwei.changeCommandTask;

import com.dyh.quickdemozwei.util.DateUtil;
import com.google.common.collect.Lists;
import lombok.Getter;
import lombok.Setter;
import lombok.SneakyThrows;
import org.apache.commons.cli.*;
import org.apache.commons.lang3.time.DateUtils;

import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @Author: yhdong
 * @Date: 2021/9/29 19:53
 */
@Setter@Getter
public class PullOrderTask {

   private static final Options options = new Options();
   private static final CommandLineParser parser = new DefaultParser();

    static {
//       // 添加 -无参数参数
//       options.addOption("h", false, "Lists short help");
       // 添加 -t 有参数
       options.addOption("st", true, "开始时间");
       options.addOption("et", true, "结束时间");
   }




    private String arg;



    @SneakyThrows
    static PullOrderTask from(String arg) {
        //String []args = arg.split("\\s+-");
       // String []args = arg.split("\\s+-");
        String []args = arg.split("\\s+-");
        String []argss = Arrays.stream(args).map(e->e.replaceAll("'","")).toArray(String[]::new);
        CommandLine commandLine = parser.parse(options,argss);
        PullOrderTask task = new PullOrderTask();
        task.setArg(arg);

        String st = commandLine.getOptionValue("st");
        String et = commandLine.getOptionValue("et");
        task.setStartTime(DateUtil.str2Date(st));
        task.setEndTime(DateUtil.str2Date(et));
//        task.setIds();

        return task;
    }

    Date startTime;
    Date endTime;
    List<Long> ids;


    public static void main(String[] args) {
//        PullOrderTask orderTask = PullOrderTask.from("-st '2021-09-29 20:05:10' -et '2021-09-29 20:05:15'");
//        System.out.println();

//        List<Integer> n= Lists.newArrayList(1,2,3,4);
        List<Integer> n= Lists.newArrayList(1,2);
        List<Integer> o = Lists.newArrayList(1,2,3);

        n.removeAll(o);

        System.out.println();

    }

}
